﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Web;

namespace TheHeGeoServer.Util
{
    public class SendEmail
    {
        public static void SendingEmail(List<string> to,
                                    string form, string subj,
                                    string body, string host, int port,
                                    string userName, string passw)
        {
            try
            {
                var mail = new MailMessage();
                foreach (var t in to)
                {
                    mail.To.Add(t);
                }
                mail.From = new MailAddress(form);
                mail.Subject = subj;
                mail.Body = body;
                mail.IsBodyHtml = true;

                var smtp = new SmtpClient();
                smtp.Host = host; //Or Your SMTP Server Address,"smtp.gmail.com"
                smtp.Credentials = new NetworkCredential(userName, passw); //Or your Smtp Email ID and Password
                smtp.EnableSsl = true;
                smtp.Port = port; //587; //If not work, you can use 25 here....
                smtp.Send(mail);
            }
            catch (Exception)
            {

            }
        }
    }
}